#include <iostream>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include "errno.h"
#include <stdio.h>

void mycleanfunc(void *arg)
{
    printf("my clean func:%d\n", *((int *)arg));
}

void *thfrunc1(void *arg)
{
    int m = 1, n = 2;
    printf("thfunc1 comes \n");
    pthread_cleanup_push(mycleanfunc, &m);
    pthread_cleanup_push(mycleanfunc, &n);
    pthread_cleanup_pop(1);
    return (void *)0;
    pthread_cleanup_pop(0);
}

int main()
{
    pthread_t pid1;
    int res;
    res = pthread_create(&pid1, NULL, thfrunc1, NULL);
    pthread_join(pid1, NULL);
    printf("main over\n");
    return 0;
}